const mongoose = require('mongoose')

const imageSchema = new mongoose.Schema({
    title:{
        type:String,
        maxlength:128,
        required:true,
        minlength:3
    },
    description:{
        type:String,
        maxlength:1024,
        required:true
    },
    originalname:{
        type:String,
        maxlength:128,
        required:true
    },
    mimetype:{
        type:String,
        enum:['image/jpeg','image/png'],
        required:true
    },
    diskfilename:{
        type:String,
        required:true
    },
    likes:{
        type:Number,
        default:0,
        required:true
    },
    visit:{
        type:Number,
        required:true,
        default:0
    },
    nickname: {
        type: String,
        required: true,
    }
},{timestamps:true})

mongoose.model('Image',imageSchema,'images')